<?php

declare(strict_types=1);

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * 亲密度记录
 */
class CloseFriendLog extends Model
{
    protected $table = 'user_close_friend_log';
    protected $fillable = ['user_id', 'frd_user_id', 'flag', 'close_value', 'from'];

    static function getLogs($userId = 0, $frdUserId = 0)
    {
        $where = ['user_id' => $userId, 'frd_user_id' => $frdUserId];
        $orWhere = ['frd_user_id' => $userId, 'user_id' => $frdUserId];
        return self::where($where)->orWhere(function ($query) use ($orWhere) {
            $query->where($orWhere);
        })->orderBy('id', 'desc')->select(['close_value', 'created_at'])->get()->toArray();
    }
}
